(function (Arena) {
    Laya.init(750, 1334, Laya.WebGL);

    Laya.stage.alignH = Laya.Stage.ALIGN_CENTER;
    Laya.stage.alignV = Laya.Stage.ALIGN_MIDDLE;
    Laya.stage.screenMode = Laya.Stage.SCREEN_VERTICAL;
    Laya.stage.scaleMode = Laya.Stage.SCALE_FIXED_HEIGHT;

    Laya.URL.basePath = CDN_URL;
    Laya.URL.version  = Arena.VERSION;

    setTimeout(function () {
        Arena.UserID = userId;

        Arena.Stage = new Laya.Box();
        Arena.Stage.width = Laya.stage.width;
        Arena.Stage.height = Laya.stage.height;
        
        Arena.UserLogged = (GM ? GM.userLogged : false);
        Arena.LoginUrl = (GM ? GM.userLoginUrl : "/?act=user&st=login");
        
        Laya.stage.addChildren(Arena.Stage, Laya.Dialog.manager);
        Laya.SoundManager.musicVolume = 0.1;

        viewer.publish("arena.start");

        Laya.stage.on(Laya.Event.RESIZE, this, function () {
            Arena.Stage.width = Laya.stage.width;
            Arena.Stage.height = Laya.stage.height;

            viewer.publish("arena.resize");
        });

        setTimeout(function() {
            Laya.stage.event(Laya.Event.RESIZE);
        }, 100);
    }, 0);

})(window.Arena);